//
//  Functions.h
//  Wood
//
//  Created by Wayne on 9/10/14.
//  Copyright (c) 2014 Wayne. All rights reserved.
//

#ifndef Wood_Functions_h
#define Wood_Functions_h

#include "Arch.h"

/* Utils.c */
Variable *searchVariableFromFrame(Frame *frame, char *name);
void addVariableToFrame(Frame *frame, char *name, Value *value);
Frame *createFrame(void);
void disposeFrame(Frame *frame);
FunctionDefinition *searchFunctionDefinitionFromFrame(Frame *frame, char *identifier);
void addFunctionDefinitionToFrame(Frame *frame, char *identifier, ParameterList *parameterList, Block *block);

/* Eval.c */
Value evalExpression(Frame *frame, Expression *expr);
Value evalBinaryExpression(Frame *frame, ExpressionType operator, Expression *left, Expression *right);
Value evalMinusExpression(Frame *frame, Expression *operand);

/* Constructors.c */
Expression *createAssignExpression(char *variable, Expression *operand);
Expression *createBinaryExpression(ExpressionType operator, Expression *left, Expression *right);
Expression *createIdentifierExpression(char *identifier);
Expression *createMinusExpression(Expression *operand);
Expression *createBoolExpression(BOOL boolValue);
Expression *createIntExpression(int intValue);
Expression *createDoubleExpression(double doubleValue);
Expression *createStringExpression(String *stringValue);
Expression *createFunctionCallExpression(char *identifier, ArgumentList *argument);
Statement *createFunctionDefinitionStatement(char *identifier, ParameterList *parameter, Block *block);
Statement *createReturnStatement(Expression *expr);

/* String.c */
String *createString(char *str);

/* Execute.c */
StatementResult executeStatementList(Frame *frame, StatementList *statementList);

#endif